package stup

import (
	"go-python/gorpc/handler"
	"net/rpc"
)

type HelloServiceStup struct {
	*rpc.Client
}

type HelloServicer interface {
	Hello(request string, reply *string) error
}

func NewHelloServiceClient(protol, address string) HelloServiceStup {
	conn, _ := rpc.Dial(protol, address)
	return HelloServiceStup{
		conn,
	}
}

func (c *HelloServiceStup) Hello(request string, reply *string) error {
	err := c.Call(handler.HelloServiceName+".Hello", request, reply)
	return err
}

func RegisterHelloService(srv HelloServicer) error {
	return rpc.RegisterName(handler.HelloServiceName, srv)
}
